package com.yyk.yykywd.mvvm.view_model

import androidx.lifecycle.MutableLiveData
import com.yyk.yykywd.mvvm.entity.FullContractBean
import com.yyk.yykywd.mvvm.model.ReturnMoneyModel
import java.util.ArrayList

/**
 * 文件描述：
 * Created by guo on 2019-11-19.
 */
class ReturnMoneyViewModel : BaseViewModel() {
    var returns: MutableList<FullContractBean.Data> = ArrayList()
    var type: String = ""

    private val returnMoneyModel: ReturnMoneyModel = ReturnMoneyModel()

    //LiveData,使该数据可以被感知
    var fullContract = MutableLiveData<FullContractBean>()

    fun getReturnMoneyList() {
        returnMoneyModel.getReturnMoneyList(type, page.toString(), num.toString(), object : ReturnMoneyModel.GetFullContract {
            override fun getInfo(fullContract: FullContractBean) {
                fullContract.data?.let { returns.addAll(it) }
                this@ReturnMoneyViewModel.fullContract.value = fullContract
            }

            override fun onError(e: String) {
                error.value = e
            }

        })
    }
}